package mviewer.types;

public class Polygon3d implements IPolygon {

	private IVertex[] vertices;
	private int[] vertexIndices;
	private IVector normal;
	private Material material;

	public Polygon3d(int[] vertexIndices, IVertex[] vertices, IVector normal, Material material) {
		if (vertices == null || vertices.length < 3)
			throw new IllegalArgumentException(String.format("A polygon at least requires three vertices. %d given.", vertices.length));
		if (material == null)
			throw new IllegalArgumentException("material cannot be null");
		if (vertexIndices == null)
			throw new IllegalArgumentException("vertexIndices cannot be null");
		this.vertexIndices = vertexIndices;
		this.vertices = vertices;
		this.normal = normal;
		this.material = material;
	}

	public int[] getVertexIndices() {
		return vertexIndices;
	}

	@Override
	public IVertex[] getVertices() {
		return vertices;
	}

	public IVector getNormal() {
		return normal;
	}

	public Material getMaterial() {
		return material;
	}

	public void setMaterial(Material material) {
		this.material = material;
	}

	public ITexturedPolygon getTexturedPolygon() {
		return null;
	}

	@Override
	public String toString() {
		return String.format("%s{%s}", getClass().getSimpleName(), material);
	}
}